package com.tanhua.app.controller;

import com.tanhua.app.service.CommentService;
import com.tanhua.app.service.QuanZiService;
import com.tanhua.app.service.VideoService;
import com.tanhua.vo.UserHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
public class CommentController {

    @Autowired
    private VideoService videoService;

    @Autowired
    private CommentService commentService;
    @Autowired
    private QuanZiService quanZiService;

    @GetMapping(value = "/comments", name = "评论列表")
    public ResponseEntity findCommentVoByPage(Integer page, Integer pagesize, String movementId) {
        return commentService.findCommentVoByPage(page, pagesize, movementId);
    }

    //评论 +10
    @PostMapping(value = "/comments", name = "发布评论")
    public ResponseEntity saveComment(@RequestBody Map<String, String> map) {

        String movementId = map.get("movementId");//动态编号
        String comment = map.get("comment");//评论
        commentService.saveComment(movementId, comment);
        quanZiService.toBigDate(4,movementId);
        return ResponseEntity.ok(null);
    }
    @GetMapping(value = "/comments/{id}/like", name = "评论点赞")
    public ResponseEntity commentLike(@PathVariable("id") String id) {
        System.out.println(id);
       return commentService.commentLike(id);
    }
    @GetMapping(value = "/comments/{id}/dislike", name = "取消评论点赞")
    public ResponseEntity commentDislike(@PathVariable("id") String id) {
        System.out.println(id);
        return commentService.commentDislike(id);
    }


}
